import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// 不能和 HelloServlet.java内(/hello)一样 不然程序会直接退出
//@WebServlet("/hello")     error
@WebServlet("/method")
public class MethodServlet extends HttpServlet {
    @Override
    //这里是post请求 直接通过浏览器不能访问到
    //因为浏览器是get请求 通过URL就能构造
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html; charset=utf8");//       注意是text/html  不是test/html
        resp.getWriter().write("POST 响应");
    }
}